package com.thb.business.service.Impl;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.thb.business.dao.IArticleDao;
import com.thb.business.model.Article;
import com.thb.business.model.ArticlePara;
import com.thb.business.service.IArticleService;

@Service
public class ArticleServiceImpl implements IArticleService {
	
	Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private IArticleDao articleDao;

	@Override
	public List<Article> findByPara(ArticlePara para) {
		return articleDao.findByPara(para);
	}
	
	/**
	 * 查询专题详情
	 */
	@Override
	public HashMap<String, List<Article>> findSpecialAllByPara(ArticlePara para) {
		String[] labels = para.getLabel().split(",");
		HashMap<String, List<Article>> json = new HashMap<String, List<Article>>();
		for(int i = 0;i<labels.length;i++){
			ArticlePara para1 = new ArticlePara();
			para1.setLabel(labels[i]);
			para1.setParId(para.getParId());
			List<Article> aList = findSpecialByPara(para1);
			json.put(para1.getLabel(), aList);
		}
		return json;
	}
	
	@Override
	public List<Article> findSpecialByPara(ArticlePara para) {
		return articleDao.findSpecialByPara(para);
	}
	
	@Override
	public int countByPara(ArticlePara para) {
		return articleDao.countByPara(para);
	}
}
